<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <el-select placeholder='类型' v-model="s_search.CMIDproduct_classid">
        <el-option label="类型" value='' />
        <el-option v-for="dict in s_class" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select>
      <el-select placeholder='类别' v-model="s_search.CMIDproduct_higher">
        <el-option label="类别" value='' />
        <el-option v-for="dict in s_higher" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select>
      <div>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品 </span>
      </div>
      <el-table :data="pageList" v-loading="loading">
        <el-table-column label="" prop="product_id" width="80">
          <template slot-scope="scope">
            <el-button @click="$parent.$parent.closeProductChoce(scope.row['product_id'],scope.row['s_product_name']);" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
          </template>
        </el-table-column>
        <el-table-column label="产品条形码" prop="product_barcode">
        </el-table-column>
        <el-table-column label="产品名称" prop="product_name">
        </el-table-column>
        <el-table-column label="产品型号" prop="product_model">
        </el-table-column>
        <el-table-column label="产品规格" prop="product_norm">
        </el-table-column>
        <el-table-column label="操作" prop="">
          <template slot-scope="scope">
            <el-button @click="popPriceSystem('&CMIDproduct_id='+scope.row.product_id+'')" type='primary' size="mini">查看价格</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="PriceSystemVisible" append-to-body>
      <PriceSystem v-if="PriceSystemVisible" ref="PriceSystem" :popparams="popparams"> </PriceSystem>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import PriceSystem from "@/views/crm/sale/PriceSystem";
  export default {
    name: 'ProductChoce',
    components: {
      PriceSystem,
    },
    props: ['popparams'],
    data() {
      return {
        PriceSystemVisible: false,
        PriceSystemValue: null,
        PriceSystemDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {
          CMIDproduct_classid: null,
          CMIDproduct_higher: null,
        },
        s_product: [],
        s_class: [],
        s_higher: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/PriceAction/productChoce?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      getPage(page) {
        this.loading = true;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/PriceAction/s_product?' + this.vueparams,
          params: {
            pageNo: page
          }
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      popPriceSystem(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PriceSystemVisible = !this.PriceSystemVisible;
      },
    },
  }
</script>
